package 尚硅谷juc大厂.test10;

import java.util.concurrent.TimeUnit;

public class Test10 {

    static volatile boolean isStop=false;
    public static void main(String[] args) throws InterruptedException {

        new Thread(()->{
            while (true){
                if (isStop){
                    System.out.println("程序结束............");
                    break;
                }
                System.out.println("t1线程运行输出");
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"t1").start();

        TimeUnit.SECONDS.sleep(5);

        new Thread(()->{
           isStop=true;
        },"t2").start();
    }
}
